Dr. Chan, Chun-Hsiang @ Department of Geography,
National Taiwan Normal University, Taipei, Taiwan
# import packages
import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import random
import matplotlib.cm as cm
# load data
df = pd.read_table('email-Eu-core.txt', header=None, sep=' ')
df.columns = ['source','target']
print('number of rows:',df.shape[0])
df.head()
number of rows: 25571
source | target | |
---|---|---|
0 | 0 | 1 |
1 | 2 | 3 |
2 | 2 | 4 |
3 | 5 | 6 |
4 | 5 | 7 |
# from pandas to networkx
G = nx.from_pandas_edgelist(df, source='source', target='target', edge_attr=None)
# for directed: create_using=nx.DiGraph()
# number of components
num_conn_comp = nx.number_connected_components(G)
print('number of connected components:',num_conn_comp)
# get the node set from one connected components
G_c0_nodelist = nx.node_connected_component(G, 0)
print('number of nodes in the 0 component:',len(G_c0_nodelist))
number of connected components: 20 number of nodes in the 0 component: 986
# The number of maximal cliques in G
max(len(c) for c in nx.find_cliques(G))
18
# The largest maximal clique in G
max(nx.find_cliques(G), key=len)
[6, 3, 4, 2, 412, 58, 63, 252, 57, 859, 408, 59, 685, 137, 56, 281, 520, 286]
# print({n: sum(1 for c in nx.find_cliques(G) if n in c) for n in G})
# the size of the largest maximal clique containing each given node
nx.node_clique_number(G, nodes=10)
10
# the maximal cliques in G that contain a given node
[c for c in nx.find_cliques(G) if 31 in c]
[[24, 23, 28, 96, 261, 151, 31, 37], [24, 23, 28, 96, 261, 151, 31, 367], [24, 23, 28, 27, 29, 37, 30, 34, 35, 40, 32, 33, 31], [24, 23, 28, 27, 29, 37, 30, 34, 35, 40, 32, 151, 31], [24, 23, 28, 27, 29, 37, 30, 34, 35, 40, 38, 33, 31, 39], [24, 23, 28, 27, 29, 37, 30, 34, 35, 40, 151, 39, 31], [24, 23, 28, 27, 29, 37, 30, 34, 35, 36, 31], [24, 23, 28, 27, 29, 37, 30, 261, 32, 40, 151, 35, 31], [24, 23, 28, 367, 35, 30, 31, 36], [24, 23, 28, 367, 35, 30, 31, 151, 32, 261], [24, 23, 28, 367, 35, 30, 31, 151, 39], [31, 162, 186], [31, 162, 107, 427], [31, 162, 107, 84], [31, 162, 612, 427], [31, 162, 612, 84], [31, 612, 82, 115, 121, 282, 424], [31, 612, 82, 115, 121, 282, 427], [31, 612, 82, 115, 121, 282, 84], [31, 165, 256, 82, 121, 186], [31, 165, 256, 82, 121, 28, 115, 107, 142, 338, 367], [31, 165, 256, 82, 121, 28, 115, 107, 142, 86], [31, 165, 256, 82, 121, 28, 115, 30, 86], [31, 165, 256, 82, 121, 28, 115, 30, 367], [31, 165, 256, 82, 121, 28, 51, 30], [31, 165, 256, 82, 170, 107, 115, 28, 338, 367], [31, 165, 256, 82, 170, 107, 115, 28, 86], [31, 165, 256, 254, 186, 121], [31, 165, 256, 254, 107, 367, 115, 28, 121, 142], [31, 165, 256, 254, 107, 367, 115, 28, 170], [31, 165, 198, 51], [31, 165, 198, 229], [31, 165, 361, 438, 34, 32, 40, 27, 29, 151], [31, 165, 361, 438, 107, 96, 115, 367], [31, 165, 361, 438, 261, 115, 96, 367], [31, 165, 361, 438, 261, 151, 32, 40, 27, 29], [31, 165, 361, 438, 261, 151, 32, 367], [31, 165, 361, 438, 261, 151, 96, 367], [31, 165, 361, 438, 135, 96, 115], [31, 165, 361, 438, 135, 40, 27], [31, 165, 338, 337, 170, 438, 96, 115, 82, 123], [31, 165, 338, 337, 170, 438, 96, 115, 82, 367], [31, 165, 338, 337, 170, 438, 96, 115, 135], [31, 165, 338, 337, 170, 438, 27, 82], [31, 165, 338, 337, 170, 438, 27, 135], [31, 165, 338, 28, 27, 438, 82, 121], [31, 165, 338, 28, 27, 438, 82, 170], [31, 165, 338, 28, 27, 438, 35, 32], [31, 165, 338, 28, 27, 438, 35, 121], [31, 165, 338, 28, 27, 438, 35, 170], [31, 165, 338, 28, 229, 170, 115], [31, 165, 338, 28, 367, 32, 35, 438], [31, 165, 338, 28, 367, 107, 82, 115, 96, 438, 121], [31, 165, 338, 28, 367, 107, 82, 115, 96, 438, 170], [31, 165, 338, 28, 367, 107, 82, 115, 932, 142], [31, 165, 338, 28, 367, 107, 35, 438, 121], [31, 165, 338, 28, 367, 107, 35, 438, 170], [31, 165, 51, 261, 121, 27, 28, 30, 82], [31, 165, 51, 261, 121, 27, 28, 30, 35, 29], [31, 165, 23, 337, 438, 170, 96, 115, 82, 367], [31, 165, 23, 337, 438, 170, 96, 115, 135], [31, 165, 23, 337, 438, 170, 27, 82], [31, 165, 23, 337, 438, 170, 27, 135], [31, 165, 23, 337, 438, 30, 82, 115, 367], [31, 165, 23, 337, 438, 30, 82, 27], [31, 165, 23, 337, 438, 30, 135, 115], [31, 165, 23, 337, 438, 30, 135, 27], [31, 165, 23, 427, 40, 170, 261, 438, 151], [31, 165, 23, 427, 86, 82, 115, 107, 96, 438, 121], [31, 165, 23, 427, 86, 82, 115, 107, 96, 438, 170], [31, 165, 23, 427, 86, 82, 115, 107, 932, 142], [31, 165, 23, 427, 86, 82, 115, 107, 142, 121], [31, 165, 23, 427, 86, 82, 115, 261, 96, 438, 121], [31, 165, 23, 427, 86, 82, 115, 261, 96, 438, 170], [31, 165, 23, 427, 86, 82, 151, 96, 261, 438, 121], [31, 165, 23, 427, 86, 82, 151, 96, 261, 438, 170], [31, 165, 23, 427, 86, 82, 151, 142, 121], [31, 165, 23, 427, 367, 82, 115, 107, 96, 438, 121], [31, 165, 23, 427, 367, 82, 115, 107, 96, 438, 170], [31, 165, 23, 427, 367, 82, 115, 107, 932, 142], [31, 165, 23, 427, 367, 82, 115, 107, 142, 121], [31, 165, 23, 427, 367, 82, 115, 261, 96, 438, 121], [31, 165, 23, 427, 367, 82, 115, 261, 96, 438, 170], [31, 165, 23, 427, 367, 82, 151, 96, 261, 438, 121], [31, 165, 23, 427, 367, 82, 151, 96, 261, 438, 170], [31, 165, 23, 427, 367, 82, 151, 142, 121], [31, 165, 23, 427, 367, 254, 107, 115, 170], [31, 165, 23, 427, 367, 254, 107, 115, 142, 121], [31, 165, 23, 427, 367, 254, 107, 115, 142, 932], [31, 165, 23, 28, 932, 107, 142, 115, 82, 86], [31, 165, 23, 28, 932, 107, 142, 115, 82, 367], [31, 165, 23, 28, 932, 107, 142, 115, 254, 367], [31, 165, 23, 28, 229, 29, 30, 39], [31, 165, 23, 28, 229, 86, 115, 170], [31, 165, 23, 28, 229, 86, 115, 30], [31, 165, 23, 28, 229, 86, 39, 30], [31, 165, 23, 28, 39, 35, 30, 151, 34, 40, 27, 29], [31, 165, 23, 28, 39, 35, 30, 151, 86], [31, 165, 23, 28, 39, 35, 30, 151, 367], [31, 165, 23, 28, 39, 35, 30, 33, 38, 34, 40, 27, 29], [31, 165, 23, 28, 39, 35, 30, 33, 38, 86], [31, 165, 23, 28, 142, 121, 107, 115, 82, 86], [31, 165, 23, 28, 142, 121, 107, 115, 82, 367], [31, 165, 23, 28, 142, 121, 107, 115, 254, 367], [31, 165, 23, 28, 142, 121, 151, 82, 86], [31, 165, 23, 28, 142, 121, 151, 82, 367], [31, 165, 23, 28, 438, 96, 82, 107, 115, 121, 86], [31, 165, 23, 28, 438, 96, 82, 107, 115, 121, 367], [31, 165, 23, 28, 438, 96, 82, 107, 115, 170, 86], [31, 165, 23, 28, 438, 96, 82, 107, 115, 170, 367], [31, 165, 23, 28, 438, 96, 82, 261, 121, 115, 86], [31, 165, 23, 28, 438, 96, 82, 261, 121, 115, 367], [31, 165, 23, 28, 438, 96, 82, 261, 121, 151, 86], [31, 165, 23, 28, 438, 96, 82, 261, 121, 151, 367], [31, 165, 23, 28, 438, 96, 82, 261, 170, 115, 86], [31, 165, 23, 28, 438, 96, 82, 261, 170, 115, 367], [31, 165, 23, 28, 438, 96, 82, 261, 170, 151, 86], [31, 165, 23, 28, 438, 96, 82, 261, 170, 151, 367], [31, 165, 23, 28, 438, 170, 115, 38, 86], [31, 165, 23, 28, 438, 170, 82, 27, 36], [31, 165, 23, 28, 438, 170, 82, 27, 261, 151], [31, 165, 23, 28, 438, 170, 82, 36, 107, 86], [31, 165, 23, 28, 438, 170, 82, 36, 107, 367], [31, 165, 23, 28, 438, 170, 35, 107, 36, 86], [31, 165, 23, 28, 438, 170, 35, 107, 36, 367], [31, 165, 23, 28, 438, 170, 35, 36, 27], [31, 165, 23, 28, 438, 170, 35, 261, 151, 40, 27], [31, 165, 23, 28, 438, 170, 35, 261, 151, 86], [31, 165, 23, 28, 438, 170, 35, 261, 151, 367], [31, 165, 23, 28, 438, 170, 35, 38, 40, 27], [31, 165, 23, 28, 438, 170, 35, 38, 86], [31, 165, 23, 28, 438, 107, 121, 35, 36, 86], [31, 165, 23, 28, 438, 107, 121, 35, 36, 367], [31, 165, 23, 28, 438, 107, 121, 36, 82, 86], [31, 165, 23, 28, 438, 107, 121, 36, 82, 367], [31, 165, 23, 28, 438, 30, 115, 261, 121, 82, 86], [31, 165, 23, 28, 438, 30, 115, 261, 121, 82, 367], [31, 165, 23, 28, 438, 30, 115, 38, 86], [31, 165, 23, 28, 438, 30, 82, 121, 36, 27], [31, 165, 23, 28, 438, 30, 82, 121, 36, 86], [31, 165, 23, 28, 438, 30, 82, 121, 36, 367], [31, 165, 23, 28, 438, 30, 82, 121, 261, 151, 27], [31, 165, 23, 28, 438, 30, 82, 121, 261, 151, 86], [31, 165, 23, 28, 438, 30, 82, 121, 261, 151, 367], [31, 165, 23, 28, 438, 30, 35, 27, 29, 121, 36], [31, 165, 23, 28, 438, 30, 35, 27, 29, 121, 261, 151], [31, 165, 23, 28, 438, 30, 35, 27, 29, 34, 40, 32, 33], [31, 165, 23, 28, 438, 30, 35, 27, 29, 34, 40, 32, 151], [31, 165, 23, 28, 438, 30, 35, 27, 29, 34, 40, 38, 33], [31, 165, 23, 28, 438, 30, 35, 27, 29, 34, 36], [31, 165, 23, 28, 438, 30, 35, 27, 29, 261, 32, 40, 151], [31, 165, 23, 28, 438, 30, 35, 86, 33, 38], [31, 165, 23, 28, 438, 30, 35, 86, 121, 36], [31, 165, 23, 28, 438, 30, 35, 86, 121, 261, 151], [31, 165, 23, 28, 438, 30, 35, 367, 36, 121], [31, 165, 23, 28, 438, 30, 35, 367, 261, 151, 32], [31, 165, 23, 28, 438, 30, 35, 367, 261, 151, 121], [31, 165, 23, 28, 254, 107, 170, 115, 367], [31, 165, 23, 135, 40, 27, 438, 170], [31, 165, 23, 135, 40, 27, 438, 30], [31, 165, 186, 932, 82], [31, 165, 186, 932, 254], [31, 37, 123, 96, 338], [31, 37, 28, 338, 32, 27, 35], [31, 37, 28, 338, 96], [31, 37, 28, 338, 229], [31, 37, 28, 23, 229, 30, 39, 29], [31, 37, 28, 23, 229, 30, 39, 86], [31, 37, 28, 23, 86, 96, 261, 151], [31, 37, 28, 23, 86, 35, 30, 36], [31, 37, 28, 23, 86, 35, 30, 261, 151], [31, 37, 28, 23, 86, 35, 30, 39, 33, 38], [31, 37, 28, 23, 86, 35, 30, 39, 151], [31, 37, 84, 229, 338], [31, 37, 84, 229, 30, 86, 39], [31, 424, 82, 115, 256, 28, 121, 142, 338, 367], [31, 424, 82, 115, 256, 28, 121, 142, 282], [31, 424, 82, 115, 256, 28, 121, 142, 86], [31, 424, 82, 115, 256, 28, 121, 30, 86], [31, 424, 82, 115, 256, 28, 121, 30, 367], [31, 424, 82, 115, 256, 28, 170, 338, 367], [31, 424, 82, 115, 256, 28, 170, 282], [31, 424, 82, 115, 256, 28, 170, 86], [31, 424, 82, 115, 337, 367, 170, 338], [31, 424, 82, 115, 337, 367, 30], [31, 424, 82, 151, 28, 86, 121, 142], [31, 424, 82, 151, 28, 86, 121, 30], [31, 424, 82, 151, 28, 86, 170], [31, 424, 82, 151, 28, 367, 121, 142], [31, 424, 82, 151, 28, 367, 121, 30], [31, 424, 82, 151, 28, 367, 170], [31, 143, 82, 121, 51], [31, 143, 82, 121, 142, 86], [31, 143, 229, 86], [31, 84, 115, 121, 107, 142, 82, 338], [31, 84, 115, 121, 107, 142, 82, 282], [31, 84, 115, 121, 107, 142, 82, 86], [31, 84, 115, 121, 107, 142, 254, 282], [31, 84, 115, 121, 30, 82, 86], [31, 84, 115, 229, 338], [31, 84, 115, 229, 86, 30], [31, 282, 33, 35, 28], [31, 282, 107, 115, 170, 256, 28, 82], [31, 282, 107, 115, 170, 256, 28, 254], [31, 282, 107, 115, 170, 427, 82], [31, 282, 107, 115, 170, 427, 254], [31, 282, 107, 115, 142, 82, 121, 256, 28], [31, 282, 107, 115, 142, 82, 121, 427], [31, 282, 107, 115, 142, 82, 932, 427], [31, 282, 107, 115, 142, 82, 932, 28], [31, 282, 107, 115, 142, 254, 121, 256, 28], [31, 282, 107, 115, 142, 254, 121, 427], [31, 282, 107, 115, 142, 254, 932, 427], [31, 282, 107, 115, 142, 254, 932, 28], [31, 282, 107, 35, 28, 121], [31, 282, 107, 35, 28, 170], [31, 155, 337, 115, 367]]
# find k-core
sub_G_kcore = nx.algorithms.core.k_core(G, k=30)
sub_G_kcore.nodes
NodeView((513, 2, 3, 4, 5, 6, 518, 520, 13, 16, 17, 531, 20, 21, 533, 23, 28, 30, 546, 552, 41, 42, 44, 46, 54, 55, 56, 57, 58, 59, 62, 63, 64, 68, 74, 80, 81, 82, 83, 84, 86, 87, 89, 93, 96, 612, 615, 105, 106, 107, 113, 114, 115, 116, 121, 128, 129, 131, 132, 133, 137, 142, 145, 147, 152, 153, 154, 155, 160, 162, 163, 165, 166, 168, 169, 170, 172, 173, 174, 685, 180, 183, 184, 187, 188, 189, 208, 209, 210, 211, 212, 215, 221, 222, 223, 226, 738, 233, 236, 249, 252, 254, 255, 256, 263, 269, 271, 280, 281, 282, 283, 285, 286, 290, 296, 809, 300, 301, 812, 303, 305, 820, 314, 318, 329, 333, 338, 340, 859, 351, 355, 356, 357, 362, 363, 365, 366, 367, 371, 375, 377, 393, 404, 405, 408, 411, 412, 419, 420, 932, 422, 424, 427, 434, 438, 450, 459, 460, 473, 474, 481, 486, 490, 493, 494, 495))
# the core number for each vertex
# A k-core is a maximal subgraph that contains nodes of degree k or more.
# The core number of a node is the largest value k of a k-core containing that node.
nx.algorithms.core.core_number(G)
{0: 27, 1: 28, 2: 32, 3: 32, 4: 32, 5: 32, 6: 31, 7: 23, 8: 21, 9: 20, 10: 29, 11: 27, 12: 25, 13: 33, 14: 28, 15: 25, 16: 34, 17: 34, 18: 29, 19: 29, 20: 32, 21: 34, 22: 12, 23: 33, 24: 26, 25: 26, 26: 26, 27: 29, 28: 34, 29: 29, 30: 32, 31: 29, 32: 26, 33: 26, 34: 26, 35: 29, 36: 29, 37: 26, 38: 27, 39: 27, 40: 29, 41: 34, 42: 34, 43: 12, 44: 34, 45: 25, 46: 34, 47: 29, 48: 29, 49: 13, 50: 13, 51: 29, 52: 18, 53: 27, 54: 30, 55: 30, 56: 30, 57: 30, 58: 34, 59: 30, 60: 27, 61: 27, 62: 34, 63: 34, 64: 34, 65: 28, 66: 23, 67: 9, 68: 30, 69: 29, 70: 17, 71: 13, 72: 7, 73: 21, 74: 32, 75: 18, 76: 20, 77: 21, 78: 21, 79: 28, 80: 32, 81: 34, 82: 34, 83: 34, 84: 33, 85: 25, 86: 34, 87: 34, 88: 24, 89: 31, 90: 21, 91: 21, 92: 25, 93: 32, 94: 26, 95: 27, 96: 32, 97: 16, 98: 17, 99: 19, 100: 20, 101: 19, 102: 17, 103: 27, 104: 26, 105: 34, 106: 34, 107: 34, 108: 26, 109: 5, 110: 8, 111: 8, 112: 17, 113: 32, 114: 34, 115: 34, 116: 32, 117: 17, 118: 23, 119: 13, 120: 16, 121: 34, 122: 20, 123: 26, 124: 21, 125: 17, 126: 27, 127: 22, 128: 34, 129: 34, 130: 24, 131: 32, 132: 32, 133: 33, 134: 14, 135: 27, 136: 27, 137: 33, 138: 27, 139: 21, 140: 21, 141: 28, 142: 34, 143: 29, 144: 13, 145: 34, 146: 23, 147: 33, 148: 15, 149: 20, 150: 27, 151: 29, 152: 34, 153: 34, 154: 34, 155: 33, 156: 16, 157: 27, 158: 28, 159: 25, 160: 34, 161: 24, 162: 30, 163: 32, 164: 25, 165: 34, 166: 34, 167: 27, 168: 32, 169: 34, 170: 34, 171: 29, 172: 33, 173: 34, 174: 32, 175: 11, 176: 24, 177: 27, 178: 24, 179: 27, 180: 33, 181: 27, 182: 27, 183: 34, 184: 34, 185: 16, 186: 25, 187: 34, 188: 30, 189: 30, 190: 28, 191: 27, 192: 17, 193: 21, 194: 29, 195: 27, 196: 25, 197: 26, 198: 26, 199: 27, 200: 24, 201: 29, 202: 7, 203: 27, 204: 25, 205: 23, 206: 27, 207: 24, 208: 30, 209: 33, 210: 34, 211: 34, 212: 34, 213: 21, 214: 27, 215: 32, 216: 20, 217: 17, 218: 29, 219: 18, 220: 16, 221: 30, 222: 31, 223: 30, 224: 13, 225: 25, 226: 32, 227: 17, 228: 21, 229: 26, 230: 19, 231: 27, 232: 28, 233: 33, 234: 28, 235: 20, 236: 32, 237: 23, 238: 25, 239: 11, 240: 19, 241: 19, 242: 23, 243: 29, 244: 23, 245: 29, 246: 14, 247: 16, 248: 21, 249: 34, 250: 27, 251: 27, 252: 34, 253: 29, 254: 34, 255: 34, 256: 34, 257: 19, 258: 29, 259: 21, 260: 19, 261: 29, 262: 18, 263: 32, 264: 21, 265: 21, 266: 20, 267: 16, 268: 27, 269: 34, 270: 15, 271: 32, 272: 25, 273: 20, 274: 20, 275: 24, 276: 9, 277: 19, 278: 29, 279: 8, 280: 34, 281: 32, 282: 34, 283: 34, 284: 27, 285: 32, 286: 30, 287: 18, 288: 26, 289: 8, 290: 34, 291: 23, 292: 27, 293: 18, 294: 21, 295: 29, 296: 31, 297: 15, 298: 14, 299: 18, 300: 34, 301: 32, 302: 22, 303: 34, 304: 24, 305: 30, 306: 29, 307: 20, 308: 28, 309: 25, 310: 25, 311: 25, 312: 25, 313: 16, 314: 30, 315: 8, 316: 27, 317: 21, 318: 31, 319: 10, 320: 27, 321: 27, 322: 19, 323: 20, 324: 16, 325: 24, 326: 29, 327: 24, 328: 18, 329: 34, 330: 8, 331: 21, 332: 19, 333: 34, 334: 17, 335: 18, 336: 27, 337: 29, 338: 31, 339: 29, 340: 34, 341: 13, 342: 27, 343: 19, 344: 15, 345: 20, 346: 23, 347: 20, 348: 4, 349: 16, 350: 18, 351: 30, 352: 20, 353: 20, 354: 10, 355: 34, 356: 31, 357: 30, 358: 21, 359: 20, 360: 21, 361: 29, 362: 32, 363: 34, 364: 9, 365: 34, 366: 34, 367: 34, 368: 27, 369: 7, 370: 26, 371: 34, 372: 22, 373: 28, 374: 17, 375: 31, 376: 27, 377: 30, 378: 22, 379: 27, 380: 27, 381: 24, 382: 5, 383: 5, 384: 16, 385: 22, 386: 8, 387: 26, 388: 24, 389: 27, 390: 27, 391: 19, 392: 19, 393: 32, 394: 26, 395: 27, 396: 14, 397: 27, 398: 4, 399: 18, 400: 27, 401: 25, 402: 8, 403: 18, 404: 34, 405: 34, 406: 19, 407: 19, 408: 30, 409: 29, 410: 11, 411: 32, 412: 30, 413: 23, 414: 4, 415: 4, 416: 3, 417: 29, 418: 25, 419: 34, 420: 34, 421: 27, 422: 32, 423: 26, 424: 34, 425: 21, 426: 29, 427: 32, 428: 20, 429: 20, 430: 28, 431: 18, 432: 7, 433: 17, 434: 34, 435: 10, 436: 3, 437: 27, 438: 32, 439: 3, 440: 27, 441: 27, 442: 23, 443: 29, 444: 24, 445: 23, 446: 19, 447: 20, 448: 21, 449: 1, 450: 32, 451: 12, 452: 21, 453: 27, 454: 9, 455: 29, 456: 2, 457: 22, 458: 29, 459: 30, 460: 30, 461: 19, 462: 25, 463: 1, 464: 29, 465: 14, 466: 21, 467: 24, 468: 18, 469: 16, 470: 18, 471: 13, 472: 7, 473: 34, 474: 34, 475: 2, 476: 8, 477: 11, 478: 25, 479: 4, 480: 29, 481: 30, 482: 27, 483: 27, 484: 18, 485: 23, 486: 32, 487: 12, 488: 11, 489: 29, 490: 31, 491: 17, 492: 26, 493: 34, 494: 34, 495: 34, 496: 19, 497: 16, 498: 27, 499: 21, 500: 19, 501: 14, 502: 19, 503: 12, 504: 21, 505: 12, 506: 27, 507: 5, 508: 25, 509: 29, 510: 19, 511: 18, 512: 4, 513: 32, 514: 10, 515: 27, 516: 11, 517: 11, 518: 34, 519: 17, 520: 30, 521: 11, 522: 3, 523: 14, 524: 1, 525: 21, 526: 28, 527: 17, 528: 10, 529: 20, 530: 9, 531: 33, 532: 18, 533: 34, 534: 5, 535: 10, 536: 14, 537: 27, 538: 9, 539: 8, 540: 8, 541: 18, 542: 18, 543: 26, 544: 21, 545: 23, 546: 34, 547: 24, 548: 28, 549: 29, 550: 25, 551: 17, 552: 30, 553: 7, 554: 10, 555: 16, 556: 8, 557: 18, 558: 12, 559: 7, 560: 29, 561: 1, 562: 23, 563: 16, 564: 25, 565: 12, 566: 18, 567: 3, 568: 23, 569: 21, 570: 17, 571: 20, 572: 18, 573: 18, 574: 4, 575: 11, 576: 19, 577: 11, 578: 1, 579: 18, 580: 0, 581: 23, 582: 16, 583: 1, 584: 4, 585: 10, 586: 23, 587: 14, 588: 20, 589: 23, 590: 23, 591: 8, 592: 20, 593: 26, 594: 6, 595: 1, 596: 5, 597: 15, 598: 7, 599: 13, 600: 10, 601: 28, 602: 20, 603: 1, 604: 8, 605: 3, 606: 1, 607: 27, 608: 20, 609: 4, 610: 14, 611: 23, 612: 31, 613: 8, 614: 3, 615: 32, 616: 6, 617: 6, 618: 12, 619: 8, 620: 2, 621: 16, 622: 1, 623: 8, 624: 11, 625: 6, 626: 1, 627: 14, 628: 6, 629: 4, 630: 2, 631: 2, 632: 3, 633: 0, 634: 1, 635: 10, 636: 1, 637: 3, 638: 21, 639: 5, 640: 16, 641: 16, 642: 19, 643: 13, 644: 14, 645: 4, 646: 3, 647: 11, 648: 0, 649: 9, 650: 1, 651: 15, 652: 7, 653: 0, 654: 26, 655: 26, 656: 11, 657: 1, 658: 0, 659: 1, 660: 0, 661: 23, 662: 16, 663: 17, 664: 10, 665: 25, 666: 18, 667: 25, 668: 1, 669: 6, 670: 0, 671: 25, 672: 13, 673: 1, 674: 16, 675: 0, 676: 4, 677: 2, 678: 14, 679: 17, 680: 1, 681: 19, 682: 3, 683: 8, 684: 0, 685: 30, 686: 10, 687: 7, 688: 1, 689: 2, 690: 20, 691: 0, 692: 2, 693: 5, 694: 9, 695: 21, 696: 9, 697: 4, 698: 26, 699: 19, 700: 19, 701: 1, 702: 2, 703: 0, 704: 1, 705: 7, 706: 10, 707: 21, 708: 16, 709: 3, 710: 17, 711: 0, 712: 3, 713: 3, 714: 21, 715: 5, 716: 1, 717: 8, 718: 6, 719: 11, 720: 19, 721: 5, 722: 4, 723: 9, 724: 2, 725: 13, 726: 18, 727: 4, 728: 13, 729: 8, 730: 12, 731: 0, 732: 0, 733: 9, 734: 14, 735: 7, 736: 5, 737: 1, 738: 30, 739: 6, 740: 4, 741: 5, 742: 3, 743: 3, 744: 0, 745: 6, 746: 0, 747: 29, 748: 25, 749: 5, 750: 1, 751: 7, 752: 5, 753: 17, 754: 20, 755: 1, 756: 19, 757: 3, 758: 13, 759: 2, 760: 4, 761: 1, 762: 1, 763: 1, 764: 9, 765: 18, 766: 3, 767: 6, 768: 14, 769: 3, 770: 1, 771: 8, 772: 0, 773: 1, 774: 1, 775: 1, 776: 23, 777: 13, 778: 5, 779: 3, 780: 1, 781: 3, 782: 3, 783: 7, 784: 1, 785: 4, 786: 9, 787: 1, 788: 1, 789: 10, 790: 1, 791: 6, 792: 1, 793: 5, 794: 2, 795: 1, 796: 4, 797: 4, 798: 0, 799: 6, 800: 6, 801: 2, 802: 5, 803: 16, 804: 12, 805: 4, 806: 5, 807: 6, 808: 0, 809: 30, 810: 15, 811: 8, 812: 30, 813: 18, 814: 5, 815: 17, 816: 17, 817: 5, 818: 13, 819: 5, 820: 34, 821: 2, 822: 18, 823: 18, 824: 1, 825: 4, 826: 21, 827: 1, 828: 24, 829: 4, 830: 1, 831: 1, 832: 21, 833: 7, 834: 1, 835: 7, 836: 4, 837: 1, 838: 2, 839: 2, 840: 16, 841: 6, 842: 2, 843: 2, 844: 3, 845: 24, 846: 1, 847: 21, 848: 3, 849: 6, 850: 2, 851: 11, 852: 4, 853: 1, 854: 7, 855: 5, 856: 29, 857: 4, 858: 1, 859: 32, 860: 18, 861: 1, 862: 1, 863: 1, 864: 1, 865: 9, 866: 3, 867: 4, 868: 2, 869: 6, 870: 3, 871: 1, 872: 13, 873: 2, 874: 3, 875: 1, 876: 1, 877: 9, 878: 4, 879: 1, 880: 27, 881: 1, 882: 2, 883: 10, 884: 1, 885: 4, 886: 11, 887: 3, 888: 1, 889: 4, 890: 1, 891: 2, 892: 19, 893: 2, 894: 1, 895: 3, 896: 24, 897: 1, 898: 2, 899: 1, 900: 18, 901: 1, 902: 1, 903: 3, 904: 1, 905: 8, 906: 5, 907: 11, 908: 22, 909: 8, 910: 1, 911: 3, 912: 5, 913: 17, 914: 18, 915: 1, 916: 1, 917: 23, 918: 23, 919: 11, 920: 2, 921: 11, 922: 18, 923: 4, 924: 11, 925: 17, 926: 11, 927: 11, 928: 1, 929: 12, 930: 11, 931: 12, 932: 34, 933: 15, 934: 4, 935: 5, 936: 18, 937: 7, 938: 1, 939: 3, 940: 2, 941: 1, 942: 2, 943: 1, 944: 1, 945: 3, 946: 1, 947: 8, 948: 1, 949: 22, 950: 29, 951: 9, 952: 6, 953: 15, 954: 7, 955: 7, 956: 15, 957: 9, 958: 2, 959: 1, 960: 1, 961: 1, 962: 2, 963: 26, 964: 5, 965: 1, 966: 2, 967: 5, 968: 2, 969: 2, 970: 6, 971: 28, 972: 2, 973: 1, 974: 7, 975: 1, 976: 21, 977: 2, 978: 5, 979: 5, 980: 9, 981: 21, 982: 1, 983: 3, 984: 3, 985: 1, 986: 3, 987: 12, 988: 2, 989: 2, 990: 18, 991: 4, 992: 1, 993: 1, 994: 1, 995: 1, 996: 1, 997: 3, 998: 1, 999: 1, ...}
from community import community_louvain
comms = community_louvain.best_partition(G)
comms
{0: 3, 1: 3, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 15, 8: 15, 9: 15, 10: 10, 11: 15, 12: 15, 13: 4, 14: 7, 15: 11, 16: 10, 17: 3, 18: 3, 19: 15, 20: 10, 21: 10, 22: 10, 23: 4, 24: 4, 25: 4, 26: 4, 27: 4, 28: 4, 29: 4, 30: 4, 31: 4, 32: 4, 33: 4, 34: 4, 35: 4, 36: 4, 37: 4, 38: 4, 39: 4, 40: 4, 41: 7, 42: 10, 43: 15, 44: 15, 45: 11, 46: 11, 47: 4, 48: 4, 49: 10, 50: 10, 51: 7, 52: 14, 53: 7, 54: 1, 55: 1, 56: 1, 57: 1, 58: 1, 59: 1, 60: 14, 61: 14, 62: 10, 63: 1, 64: 7, 65: 7, 66: 10, 67: 10, 68: 10, 69: 10, 70: 10, 71: 10, 72: 10, 73: 3, 74: 3, 75: 4, 76: 4, 77: 10, 78: 10, 79: 7, 80: 10, 81: 10, 82: 10, 83: 10, 84: 10, 85: 3, 86: 15, 87: 10, 88: 1, 89: 1, 90: 10, 91: 10, 92: 10, 93: 4, 94: 7, 95: 7, 96: 4, 97: 11, 98: 11, 99: 11, 100: 11, 101: 11, 102: 1, 103: 14, 104: 14, 105: 10, 106: 10, 107: 10, 108: 10, 109: 10, 110: 10, 111: 10, 112: 10, 113: 4, 114: 4, 115: 4, 116: 4, 117: 10, 118: 10, 119: 4, 120: 3, 121: 10, 122: 7, 123: 4, 124: 11, 125: 11, 126: 1, 127: 10, 128: 7, 129: 7, 130: 7, 131: 1, 132: 1, 133: 4, 134: 10, 135: 4, 136: 4, 137: 1, 138: 1, 139: 11, 140: 11, 141: 15, 142: 10, 143: 10, 144: 10, 145: 10, 146: 3, 147: 10, 148: 7, 149: 7, 150: 14, 151: 4, 152: 10, 153: 10, 154: 10, 155: 10, 156: 14, 157: 14, 158: 1, 159: 1, 160: 14, 161: 15, 162: 10, 163: 10, 164: 11, 165: 4, 166: 10, 167: 7, 168: 7, 169: 4, 170: 4, 171: 4, 172: 7, 173: 10, 174: 1, 175: 1, 176: 7, 177: 3, 178: 7, 179: 14, 180: 7, 181: 14, 182: 14, 183: 7, 184: 10, 185: 11, 186: 10, 187: 10, 188: 10, 189: 10, 190: 10, 191: 7, 192: 1, 193: 1, 194: 1, 195: 1, 196: 7, 197: 7, 198: 7, 199: 7, 200: 7, 201: 7, 202: 7, 203: 7, 204: 7, 205: 7, 206: 7, 207: 7, 208: 1, 209: 1, 210: 1, 211: 1, 212: 10, 213: 15, 214: 7, 215: 3, 216: 11, 217: 10, 218: 3, 219: 3, 220: 3, 221: 3, 222: 3, 223: 3, 224: 3, 225: 3, 226: 3, 227: 3, 228: 3, 229: 4, 230: 10, 231: 7, 232: 7, 233: 1, 234: 1, 235: 1, 236: 1, 237: 1, 238: 1, 239: 1, 240: 1, 241: 1, 242: 1, 243: 1, 244: 1, 245: 4, 246: 15, 247: 15, 248: 3, 249: 10, 250: 14, 251: 4, 252: 1, 253: 10, 254: 10, 255: 10, 256: 10, 257: 7, 258: 10, 259: 10, 260: 10, 261: 4, 262: 7, 263: 4, 264: 15, 265: 15, 266: 15, 267: 15, 268: 3, 269: 11, 270: 7, 271: 1, 272: 11, 273: 11, 274: 11, 275: 7, 276: 7, 277: 7, 278: 7, 279: 10, 280: 7, 281: 1, 282: 10, 283: 14, 284: 7, 285: 1, 286: 1, 287: 10, 288: 10, 289: 7, 290: 7, 291: 7, 292: 7, 293: 15, 294: 7, 295: 14, 296: 14, 297: 3, 298: 10, 299: 10, 300: 10, 301: 11, 302: 1, 303: 1, 304: 1, 305: 1, 306: 10, 307: 3, 308: 14, 309: 3, 310: 3, 311: 3, 312: 3, 313: 3, 314: 3, 315: 3, 316: 3, 317: 3, 318: 4, 319: 1, 320: 14, 321: 14, 322: 11, 323: 11, 324: 15, 325: 10, 326: 10, 327: 10, 328: 10, 329: 10, 330: 3, 331: 3, 332: 15, 333: 4, 334: 11, 335: 11, 336: 4, 337: 4, 338: 4, 339: 4, 340: 10, 341: 3, 342: 7, 343: 7, 344: 7, 345: 7, 346: 7, 347: 7, 348: 7, 349: 7, 350: 7, 351: 7, 352: 7, 353: 11, 354: 11, 355: 10, 356: 10, 357: 10, 358: 15, 359: 15, 360: 15, 361: 4, 362: 15, 363: 10, 364: 10, 365: 15, 366: 10, 367: 4, 368: 14, 369: 1, 370: 4, 371: 11, 372: 10, 373: 1, 374: 15, 375: 10, 376: 14, 377: 14, 378: 14, 379: 14, 380: 14, 381: 14, 382: 14, 383: 14, 384: 14, 385: 14, 386: 14, 387: 14, 388: 14, 389: 14, 390: 14, 391: 14, 392: 14, 393: 14, 394: 14, 395: 14, 396: 14, 397: 14, 398: 14, 399: 7, 400: 10, 401: 7, 402: 7, 403: 7, 404: 11, 405: 10, 406: 15, 407: 15, 408: 1, 409: 4, 410: 10, 411: 1, 412: 1, 413: 7, 414: 14, 415: 14, 416: 10, 417: 4, 418: 10, 419: 10, 420: 10, 421: 15, 422: 10, 423: 4, 424: 10, 425: 7, 426: 7, 427: 4, 428: 11, 429: 11, 430: 15, 431: 10, 432: 10, 433: 10, 434: 10, 435: 10, 436: 4, 437: 4, 438: 4, 439: 4, 440: 7, 441: 15, 442: 4, 443: 4, 444: 4, 445: 7, 446: 11, 447: 11, 448: 11, 449: 14, 450: 7, 451: 15, 452: 15, 453: 10, 454: 10, 455: 4, 456: 7, 457: 7, 458: 7, 459: 3, 460: 10, 461: 11, 462: 10, 463: 10, 464: 4, 465: 10, 466: 15, 467: 10, 468: 3, 469: 10, 470: 4, 471: 10, 472: 10, 473: 10, 474: 10, 475: 10, 476: 10, 477: 10, 478: 10, 479: 14, 480: 10, 481: 1, 482: 10, 483: 7, 484: 7, 485: 4, 486: 7, 487: 15, 488: 15, 489: 10, 490: 10, 491: 10, 492: 10, 493: 7, 494: 4, 495: 10, 496: 15, 497: 10, 498: 15, 499: 15, 500: 15, 501: 15, 502: 15, 503: 15, 504: 15, 505: 15, 506: 15, 507: 3, 508: 10, 509: 10, 510: 15, 511: 7, 512: 10, 513: 10, 514: 10, 515: 7, 516: 1, 517: 1, 518: 10, 519: 3, 520: 1, 521: 10, 522: 7, 523: 7, 524: 10, 525: 15, 526: 7, 527: 4, 528: 1, 529: 15, 530: 15, 531: 10, 532: 1, 533: 15, 534: 7, 535: 10, 536: 10, 537: 3, 538: 10, 539: 14, 540: 10, 541: 10, 542: 7, 543: 7, 544: 7, 545: 4, 546: 10, 547: 4, 548: 10, 549: 10, 550: 10, 551: 10, 552: 1, 553: 10, 554: 10, 555: 15, 556: 7, 557: 7, 558: 15, 559: 10, 560: 3, 561: 10, 562: 7, 563: 7, 564: 1, 565: 15, 566: 15, 567: 7, 568: 7, 569: 15, 570: 15, 571: 1, 572: 7, 573: 15, 574: 7, 575: 7, 576: 7, 577: 10, 578: 10, 579: 11, 580: 16, 581: 7, 582: 10, 583: 10, 584: 7, 585: 7, 586: 1, 587: 1, 588: 4, 589: 10, 590: 4, 591: 10, 592: 11, 593: 7, 594: 10, 595: 14, 596: 10, 597: 10, 598: 10, 599: 1, 600: 7, 601: 1, 602: 15, 603: 14, 604: 1, 605: 7, 606: 10, 607: 10, 608: 15, 609: 4, 610: 1, 611: 7, 612: 10, 613: 10, 614: 10, 615: 10, 616: 3, 617: 11, 618: 11, 619: 1, 620: 15, 621: 7, 622: 1, 623: 7, 624: 11, 625: 1, 626: 10, 627: 10, 628: 14, 629: 3, 630: 1, 631: 1, 632: 14, 633: 17, 634: 1, 635: 1, 636: 1, 637: 1, 638: 10, 639: 1, 640: 11, 641: 10, 642: 10, 643: 10, 644: 11, 645: 14, 646: 1, 647: 10, 648: 18, 649: 15, 650: 3, 651: 10, 652: 10, 653: 19, 654: 10, 655: 4, 656: 7, 657: 11, 658: 20, 659: 14, 660: 21, 661: 15, 662: 11, 663: 10, 664: 7, 665: 1, 666: 15, 667: 10, 668: 14, 669: 10, 670: 22, 671: 10, 672: 15, 673: 10, 674: 15, 675: 23, 676: 11, 677: 7, 678: 10, 679: 10, 680: 14, 681: 7, 682: 7, 683: 1, 684: 24, 685: 1, 686: 4, 687: 11, 688: 7, 689: 7, 690: 10, 691: 25, 692: 7, 693: 10, 694: 7, 695: 3, 696: 3, 697: 14, 698: 1, 699: 15, 700: 15, 701: 10, 702: 10, 703: 26, 704: 10, 705: 7, 706: 7, 707: 15, 708: 11, 709: 11, 710: 10, 711: 8, 712: 1, 713: 10, 714: 7, 715: 10, 716: 1, 717: 1, 718: 1, 719: 14, 720: 15, 721: 4, 722: 4, 723: 10, 724: 14, 725: 4, 726: 10, 727: 10, 728: 10, 729: 15, 730: 10, 731: 9, 732: 12, 733: 10, 734: 14, 735: 11, 736: 10, 737: 1, 738: 1, 739: 10, 740: 7, 741: 14, 742: 10, 743: 1, 744: 13, 745: 3, 746: 0, 747: 10, 748: 10, 749: 7, 750: 1, 751: 7, 752: 10, 753: 4, 754: 15, 755: 1, 756: 3, 757: 4, 758: 3, 759: 3, 760: 11, 761: 14, 762: 1, 763: 1, 764: 3, 765: 15, 766: 10, 767: 10, 768: 11, 769: 10, 770: 11, 771: 10, 772: 2, 773: 10, 774: 1, 775: 3, 776: 7, 777: 10, 778: 15, 779: 7, 780: 10, 781: 3, 782: 14, 783: 10, 784: 1, 785: 4, 786: 7, 787: 10, 788: 1, 789: 7, 790: 7, 791: 7, 792: 10, 793: 10, 794: 11, 795: 4, 796: 10, 797: 7, 798: 5, 799: 10, 800: 10, 801: 7, 802: 7, 803: 1, 804: 15, 805: 15, 806: 1, 807: 1, 808: 6, 809: 1, 810: 14, 811: 10, 812: 1, 813: 7, 814: 7, 815: 1, 816: 4, 817: 7, 818: 10, 819: 11, 820: 7, 821: 14, 822: 7, 823: 15, 824: 7, 825: 10, 826: 1, 827: 15, 828: 10, 829: 7, 830: 15, 831: 10, 832: 1, 833: 15, 834: 10, 835: 7, 836: 7, 837: 10, 838: 11, 839: 14, 840: 7, 841: 14, 842: 1, 843: 7, 844: 4, 845: 1, 846: 7, 847: 4, 848: 10, 849: 1, 850: 7, 851: 7, 852: 14, 853: 10, 854: 1, 855: 10, 856: 15, 857: 11, 858: 10, 859: 1, 860: 4, 861: 7, 862: 10, 863: 1, 864: 1, 865: 1, 866: 1, 867: 10, 868: 14, 869: 14, 870: 7, 871: 7, 872: 3, 873: 7, 874: 7, 875: 4, 876: 1, 877: 10, 878: 4, 879: 1, 880: 1, 881: 4, 882: 14, 883: 4, 884: 1, 885: 10, 886: 1, 887: 10, 888: 1, 889: 10, 890: 10, 891: 4, 892: 4, 893: 15, 894: 10, 895: 4, 896: 10, 897: 4, 898: 1, 899: 1, 900: 4, 901: 1, 902: 1, 903: 7, 904: 14, 905: 3, 906: 14, 907: 7, 908: 7, 909: 7, 910: 7, 911: 10, 912: 15, 913: 15, 914: 4, 915: 4, 916: 14, 917: 7, 918: 7, 919: 4, 920: 10, 921: 1, 922: 15, 923: 10, 924: 1, 925: 4, 926: 1, 927: 1, 928: 1, 929: 11, 930: 1, 931: 1, 932: 10, 933: 11, 934: 10, 935: 11, 936: 7, 937: 11, 938: 7, 939: 7, 940: 7, 941: 10, 942: 7, 943: 14, 944: 10, 945: 10, 946: 10, 947: 14, 948: 14, 949: 1, 950: 15, 951: 15, 952: 10, 953: 4, 954: 10, 955: 7, 956: 15, 957: 15, 958: 10, 959: 14, 960: 14, 961: 14, 962: 10, 963: 1, 964: 4, 965: 7, 966: 10, 967: 15, 968: 10, 969: 10, 970: 7, 971: 15, 972: 15, 973: 15, 974: 7, 975: 15, 976: 4, 977: 1, 978: 4, 979: 3, 980: 4, 981: 4, 982: 1, 983: 4, 984: 10, 985: 14, 986: 4, 987: 4, 988: 1, 989: 10, 990: 1, 991: 1, 992: 7, 993: 1, 994: 1, 995: 1, 996: 15, 997: 4, 998: 7, 999: 10, ...}
partition = community_louvain.best_partition(G)
unique_coms = np.unique(list(comms.values()))
cmap = cm.get_cmap('viridis', max(partition.values()) + 1)
pos = nx.spring_layout(G)
cmap = cm.get_cmap('viridis', max(partition.values()) + 1)
nx.draw_networkx_nodes(G, pos, partition.keys(), node_size=40,
cmap=cmap, node_color=list(partition.values()))
nx.draw_networkx_edges(G, pos, alpha=0.8)
plt.show()
# generate random graph
G1 = nx.fast_gnp_random_graph(50, 0.2)
# weights
weights = []
# add random edge weights
for (u, v) in G1.edges():
w = random.random()*100
G1.edges[u,v]['weight'] = w
weights.append(w)
# girvan_newman community detection
comp_gn = nx.algorithms.community.girvan_newman(G1)
tuple(sorted(c) for c in next(comp_gn))
([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49], [45])
# mapequation
from infomap import Infomap
# infomap initialize
im = Infomap("-k -d")
# add to informap
im.add_networkx_graph(G)
# run infomap
im.run()
# declare empty list for storing node info and modules
infomapped1 = []
infomapped2 = []
# get node info
for node in im.nodes:
infomapped1.append([node.node_id, node.module_id, node.flow])
# get modules
for node, modules in im.get_multilevel_modules().items():
infomapped2.append([node, modules])
# transform to dataframe
info1 = pd.DataFrame.from_records(infomapped1, columns=['node_id','L1','flow'])
info2 = pd.DataFrame.from_records(infomapped2, columns=['node_id','path'])
# get module path
def get_path(info2):
path = []
for i in range(len(info2['path'])):
path.append(list(info2['path'][i]))
path = pd.DataFrame.from_records(path)
try:
path = path.iloc[:,:2]
path.columns = ['L1','L2']
except:
path.columns = ['L1']
return path
# split the module tuple and merge back to the dataframe
path = get_path(info2)
info2 = pd.concat([info2, path], axis=1)
# print info 1
info1
node_id | L1 | flow | |
---|---|---|---|
0 | 424 | 1 | 0.004619 |
1 | 405 | 1 | 0.003489 |
2 | 438 | 1 | 0.002915 |
3 | 366 | 1 | 0.002895 |
4 | 419 | 1 | 0.002832 |
... | ... | ... | ... |
1000 | 744 | 18 | 0.000000 |
1001 | 746 | 19 | 0.000000 |
1002 | 772 | 20 | 0.000000 |
1003 | 798 | 21 | 0.000000 |
1004 | 808 | 22 | 0.000000 |
1005 rows × 3 columns
# print info 2d
info2
node_id | path | L1 | L2 | |
---|---|---|---|---|
0 | 0 | (1, 1, 1, 1) | 1 | 1 |
1 | 1 | (1, 1, 1, 1) | 1 | 1 |
2 | 2 | (1, 1, 2, 2) | 1 | 1 |
3 | 3 | (1, 1, 2, 2) | 1 | 1 |
4 | 4 | (1, 1, 2, 2) | 1 | 1 |
... | ... | ... | ... | ... |
1000 | 1000 | (1, 2, 38, 40) | 1 | 2 |
1001 | 1001 | (1, 1, 2, 2) | 1 | 1 |
1002 | 1002 | (1, 2, 43, 45) | 1 | 2 |
1003 | 1003 | (1, 1, 1, 1) | 1 | 1 |
1004 | 1004 | (1, 1, 2, 2) | 1 | 1 |
1005 rows × 4 columns